package com.mdd.apiinterface.controller;

import com.mdd.apiinterface.generator.domain.Wallpaper;
import com.mdd.apiinterface.generator.mapper.WallpaperMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *
 * @author Mdd
 * @Github <a href="https://github.com/mdd123cc"/>
 * @Gitee <a href="https://gitee.com/mdd115192"/>
 *
 */
@RestController
@RequestMapping("/wallpaper")
public class wallpaperController {

    @Resource
    private WallpaperMapper wallpaperMapper;

    /**
     * 随机获取一个壁纸的url
     * @return
     */
    @PostMapping("/random")
    public String getUserNameByGet(){
        Wallpaper wallpaper = wallpaperMapper.getRandomJoke();
        if (wallpaper == null) {
            throw new RuntimeException("操作失败");
        }
        return wallpaper.getUrl();
    }

    @PostMapping("/random1")
    public String getUserNameByGet1(){
        Wallpaper wallpaper = wallpaperMapper.getRandomJoke();
        if (wallpaper == null) {
            throw new RuntimeException("操作失败");
        }
        return wallpaper.getUrl();
    }
}
